﻿using System;
using System.Collections.Generic;
using System.Text;

namespace 管道.Pipeline管道基类
{
    public class Pipeline : IPipeline
    {

        private readonly List<IPipelineHandler> _pipelineHandleList = new List<IPipelineHandler>();

        public void Push(PipelineeContextModel context)
        {
            foreach (var handle in _pipelineHandleList)
            {
                if (handle.Filter(context))
                {
                    handle.Handler(context);
                }
            }
        }

        public void AddPipelineHandle(IPipelineHandler handle)
        {
            _pipelineHandleList.Add(handle);
        }

        public void RemovePipelineHandle(IPipelineHandler handle)
        {
            _pipelineHandleList.Remove(handle);
        }

    }
}
